package emulator.unittest.hardware.nmos6502.commands;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import emulator.EmulatorException;
import emulator.hardware.HwByte;
import emulator.hardware.clock.ClockImplementation;
import emulator.hardware.memory.MemoryBlock;
import emulator.hardware.nmos6502.Cpu6502;
import emulator.hardware.nmos6502.Flags6502;
import emulator.hardware.nmos6502.commands.PHP;
import emulator.hardware.nmos6502.operands.NoOperand;

public class PHPTest {

	@Test
	public void testExecute() throws EmulatorException {
		Cpu6502 cpu = new Cpu6502();
		MemoryBlock memory = new MemoryBlock(65536);
		ClockImplementation clock = new ClockImplementation();
		cpu.attach(memory, clock);
		cpu.setSP(new HwByte(0xFF));
		cpu.setFlags(new Flags6502(Flags6502.FLAG_INTERRUPT));

		PHP php = new PHP();
		php.execute(cpu, new NoOperand());
		assertEquals(new HwByte(0xFE), cpu.getSP());
		assertEquals(cpu.getFlags(), memory.read(0x1FF));
	}

}
